<%@ Page Language="C#" MasterPageFile="~/_Templates/MasterPages/Default.master" AutoEventWireup="true" CodeFile="filters.aspx.cs" Inherits="image_manipulation_filters" Title="Untitled Page" %>
<asp:Content ID="MainContent" ContentPlaceHolderID="MainContentPlaceHolder" Runat="Server" EnableViewState="false">

<h1>Image Manipulation</h1>
<h2>Filters</h2>
<p>DNAide includes the <strong>ImageTransform</strong> control. This control is a helper and wrapper for the filter/tranform methods in the <strong>DNAide.Drawing.BitmapAide</strong> class.</p>
<p>The control provides an event, passing in the image to transform that you can then apply any number of filters/transformation to before the control saves the final image.</p>
<p>To avoid repitition, only the first filter "Grayscale" shows both aspx and codebehind. Subsequent examples show the event handler only.</p>
<p>By default, these examples are saving with a jpeg compression value of 60% which is lower compression than the original. This can be configured by the <strong>"Output"</strong> names properties of the control.</p>
<p>The following are only examples of some of the filters available. These filters are based on the code by Christian Graus which can be found at <a href="http://www.codeproject.com/cs/media/csharpgraphicfilters11.asp" class="newwindow">http://www.codeproject.com/cs/media/csharpgraphicfilters11.asp</a></p>

<h3>Original Image</h3>
<img src="../_client/images/closeup.jpg" width="300" height="193" />

<h3>Grayscale</h3>
<h4>aspx</h4>
<pre class="csharpcode">
<span class="kwrd">&lt;</span><span class="html">DNAide:ImageTransform</span> <span class="attr">ID</span><span class="kwrd">="Transform1"</span> <span class="attr">runat</span><span class="kwrd">="server"</span> <span class="attr">SourceFileName</span><span class="kwrd">="~/_client/images/closeup.jpg"</span> 
  <span class="attr">OutputFileName</span><span class="kwrd">="Transform1.jpg"</span> <span class="kwrd">/&gt;</span></pre>
<h4>codebehind</h4>
<pre class="csharpcode">
<span class="kwrd">protected</span> <span class="kwrd">override</span> <span class="kwrd">void</span> OnInit(EventArgs e)
{
  Transform1.ApplyTransformations += 
    <span class="kwrd">new</span> DNAideImageControl.ApplyTransformationsEventHandler(Transform1_ApplyTransformations);
        <span class="kwrd">base</span>.OnInit(e);
}

<span class="kwrd">void</span> Transform1_ApplyTransformations(<span class="kwrd">object</span> sender, <span class="kwrd">ref</span> Bitmap bitmapToTransform)
{
  BitmapAide.GrayScale(bitmapToTransform);
}</pre>

<DNAide:ImageTransform ID="Transform1" runat="server" SourceFileName="~/_client/images/closeup.jpg" OutputFileName="Transform1.jpg" />


<h3>Invert</h3>
<h4>codebehind</h4>
<pre class="csharpcode">
<span class="kwrd">void</span> Transform2_ApplyTransformations(<span class="kwrd">object</span> sender, <span class="kwrd">ref</span> Bitmap bitmapToTransform)
{
  BitmapAide.Invert(bitmapToTransform);
}</pre>

<DNAide:ImageTransform ID="Transform2" runat="server" SourceFileName="~/_client/images/closeup.jpg" OutputFileName="Transform2.jpg" />


<h3>Brightness</h3>
<h4>codebehind</h4>
<pre class="csharpcode">
<span class="kwrd">void</span> Transform3_ApplyTransformations(<span class="kwrd">object</span> sender, <span class="kwrd">ref</span> Bitmap bitmapToTransform)
{
  BitmapAide.Brightness(bitmapToTransform, 100);
}</pre>

<DNAide:ImageTransform ID="Transform3" runat="server" SourceFileName="~/_client/images/closeup.jpg" OutputFileName="Transform3.jpg" />


<h3>Contrast</h3>
<h4>codebehind</h4>
<pre class="csharpcode">
<span class="kwrd">void</span> Transform4_ApplyTransformations(<span class="kwrd">object</span> sender, <span class="kwrd">ref</span> Bitmap bitmapToTransform)
{
  BitmapAide.Contrast(bitmapToTransform, 100);
}</pre>

<DNAide:ImageTransform ID="Transform4" runat="server" SourceFileName="~/_client/images/closeup.jpg" OutputFileName="Transform4.jpg" />



<h3>Sharpen</h3>
<h4>codebehind</h4>
<pre class="csharpcode">
<span class="kwrd">void</span> Transform5_ApplyTransformations(<span class="kwrd">object</span> sender, <span class="kwrd">ref</span> Bitmap bitmapToTransform)
{
  BitmapAide.Sharpen(bitmapToTransform, 11);
}</pre>

<DNAide:ImageTransform ID="Transform5" runat="server" SourceFileName="~/_client/images/closeup.jpg" OutputFileName="Transform5.jpg" />


<h3>Smooth</h3>
<h4>codebehind</h4>
<pre class="csharpcode">
<span class="kwrd">void</span> Transform6_ApplyTransformations(<span class="kwrd">object</span> sender, <span class="kwrd">ref</span> Bitmap bitmapToTransform)
{
  BitmapAide.Smooth(bitmapToTransform, 11);
}</pre>

<DNAide:ImageTransform ID="Transform6" runat="server" SourceFileName="~/_client/images/closeup.jpg" OutputFileName="Transform6.jpg" />


<h3>GaussianBlur</h3>
<h4>codebehind</h4>
<pre class="csharpcode">
<span class="kwrd">void</span> Transform7_ApplyTransformations(<span class="kwrd">object</span> sender, <span class="kwrd">ref</span> Bitmap bitmapToTransform)
{
  BitmapAide.GaussianBlur(bitmapToTransform, 4);
}</pre>

<DNAide:ImageTransform ID="Transform7" runat="server" SourceFileName="~/_client/images/closeup.jpg" OutputFileName="Transform7.jpg" />


<h3>Gamma</h3>
<h4>codebehind</h4>
<pre class="csharpcode">
<span class="kwrd">void</span> Transform8_ApplyTransformations(<span class="kwrd">object</span> sender, <span class="kwrd">ref</span> Bitmap bitmapToTransform)
{
  BitmapAide.Gamma(bitmapToTransform, 1, 2, 3);
}</pre>

<DNAide:ImageTransform ID="Transform8" runat="server" SourceFileName="~/_client/images/closeup.jpg" OutputFileName="Transform8.jpg" />


<h3>Emboss</h3>
<h4>codebehind</h4>
<pre class="csharpcode">
<span class="kwrd">void</span> Transform9_ApplyTransformations(<span class="kwrd">object</span> sender, <span class="kwrd">ref</span> Bitmap bitmapToTransform)
{
  BitmapAide.Emboss(bitmapToTransform);
}</pre>

<DNAide:ImageTransform ID="Transform9" runat="server" SourceFileName="~/_client/images/closeup.jpg" OutputFileName="Transform9.jpg" />



<h3>Pixellate</h3>
<h4>codebehind</h4>
<pre class="csharpcode">
<span class="kwrd">void</span> Transform10_ApplyTransformations(<span class="kwrd">object</span> sender, <span class="kwrd">ref</span> Bitmap bitmapToTransform)
{
  BitmapAide.Pixellate(bitmapToTransform, 10, true);
}</pre>

<DNAide:ImageTransform ID="Transform10" runat="server" SourceFileName="~/_client/images/closeup.jpg" OutputFileName="Transform10.jpg" />


<h3>Wave</h3>
<h4>codebehind</h4>
<pre class="csharpcode">
<span class="kwrd">void</span> Transform11_ApplyTransformations(<span class="kwrd">object</span> sender, <span class="kwrd">ref</span> Bitmap bitmapToTransform)
{
  BitmapAide.Water(bitmapToTransform, 10, true);
}</pre>

<DNAide:ImageTransform ID="Transform11" runat="server" SourceFileName="~/_client/images/closeup.jpg" OutputFileName="Transform11.jpg" />

</asp:Content>

